﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JobAlert.aspx.cs" Inherits="JobSeeker_JobAlert" MasterPageFile="~/JobSeeker/JobSeekerMaster.master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="contentBody" ContentPlaceHolderID="MainContent" runat="server">
    <%--    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>--%>

    <asp:UpdatePanel ID="unlJobAlert" runat="server">
        <ContentTemplate>

            <div class="panel-body">

                <link href="css/jquery.tagit.css" rel="stylesheet" type="text/css" />
                <link href="css/tagit.ui-zendesk.css" rel="stylesheet" type="text/css" />
                <script src="js/tag-it.js" type="text/javascript" charset="utf-8"></script>


                <script type="text/javascript">
                    Sys.Application.add_load(Loadtagit);

                    function Loadtagit() {
                        var skills = '';
                        var list = [];
                        $.ajax({
                            type: "post",
                            url: "JobAlert.aspx/LoadSkill",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function (data) {
                                if (data.d.length > 0) {
                                    var items = [];
                                    var i;
                                    for (i = 0; i < data.d.length; i++) {
                                        if (data.d[i] !== "No data")
                                            list.push(data.d[i]);
                                    }
                                    for (i = 0; i < list.length; i++) {
                                        $('#allowSpacesTags').append('<li>' + list[i] + '</li>'); //Using Option 2
                                    }
                                    $("#allowSpacesTags").tagit({
                                        availableTags: list,
                                        allowSpaces: true,
                                        caseSensitive: false,
                                        removeConfirmation: true,
                                        sortable: true,
                                        select: true,
                                        placeholderText: "Add skills..."
                                    });
                                }
                            },
                            error: function (xmlHttpRequest, textStatus, errorThrown) {
                                $("#allowSpacesTags").tagit({
                                    availableTags: '',
                                    allowSpaces: true,
                                    caseSensitive: false,
                                    removeConfirmation: true,
                                    sortable: true,
                                    select: true,
                                    placeholderText: "Add skills..."
                                });
                                //alert(xmlHttpRequest.statusText);
                                //alert(xmlHttpRequest.responseText);
                                //alert(textStatus);
                                //alert(errorThrown);
                            }
                        });


                        $("#allowSpacesTags").keydown(function (e) {
                            if (e.keyCode == 13) {
                                //alert('You pressed enter!');
                                var values = [];
                                var array = $('#allowSpacesTags').text().split("×");
                                $.each(array, function (index, value) {
                                    if (value != "")
                                        values.push(value);
                                });
                                var skills = values.join(",");
                                $('#<%=hdnSelectedTags.ClientID %>').val($.trim(skills));
                                console.log($('#<%=hdnSelectedTags.ClientID %>').val());
                            }
                        });
                        $('#allowSpacesTags').outside('click', function (e) {
                            //alert('lost focus!');
                            var values = [];
                            var array = $('#allowSpacesTags').text().split("×");
                            $.each(array, function (index, value) {
                                if (value != "")
                                    values.push(value);
                            });
                            var skills = values.join(",");
                            $('#<%=hdnSelectedTags.ClientID %>').val($.trim(skills));
                            console.log($('#<%=hdnSelectedTags.ClientID %>').val());
                            return true;
                        });
                    }

                </script>


                <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="50" AssociatedUpdatePanelID="unlJobAlert">
                    <ProgressTemplate>
                        <div id="progressBackgroundFilter"></div>
                        <div id="processMessage">
                            <img alt="Loading..." src="/img/please_wait.gif" />
                        </div>
                    </ProgressTemplate>
                </asp:UpdateProgress>

                <!--Manage Profile Start-->
                <div class="row form-row manage-profile">
                    <!--Form Start Here-->
                    <div class="row form-body">

                        <div class="col-md-8">
                            <div class="form-horizontal manage-profile" role="form">

                                <div class="form-group">
                                    <asp:HiddenField ID="hdID" runat="server" />
                                    <asp:HiddenField ID="hdYesNo" runat="server" />
                                    <label class="col-md-3 control-label">Alert Name <i>*</i></label>
                                    <div class="col-md-9">
                                        <asp:TextBox type="text" ID="txtAlertName" CssClass="form-control" runat="server"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="reqValAlertName" runat="server" ControlToValidate="txtAlertName" ErrorMessage="Alert name missing" Display="Dynamic"
                                            Text="*" ValidationGroup="valJobAlert" Font-Bold="true" ForeColor="Red" Font-Size="Large"></asp:RequiredFieldValidator>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-3 control-label">Job Title<i>*</i></label>
                                    <div class="col-md-9">
                                        <asp:TextBox ID="txtKeyWords" runat="server" CssClass="form-control"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="reqKeyWords" runat="server" ControlToValidate="txtKeyWords" ErrorMessage="Company name missing" Display="Dynamic"
                                            Text="*" ValidationGroup="valJobAlert" Font-Bold="true" ForeColor="Red" Font-Size="Large"></asp:RequiredFieldValidator>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-3 control-label">Category<i>*</i></label>
                                    <div class="col-md-9">
                                        <asp:DropDownList ID="ddlCategory" CssClass="form-control" runat="server" AppendDataBoundItems="true"
                                            SelectMethod="Load_Category" DataTextField="Caterogy" DataValueField="ID">
                                            <asp:ListItem Value="-1" Text="--Select a job category--"></asp:ListItem>
                                        </asp:DropDownList>
                                        <asp:RequiredFieldValidator ID="reqValCategory" runat="server" ControlToValidate="ddlCategory" ErrorMessage="Category missing" Display="Dynamic"
                                            Text="*" ValidationGroup="valJobAlert" InitialValue="-1" Font-Bold="true" ForeColor="Red" Font-Size="Large"></asp:RequiredFieldValidator>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <asp:HiddenField ID="hdnSelectedTags" runat="server" />
                                    <label class="col-md-3 control-label">Skills</label>
                                    <div class="col-md-9">
                                        <div style="float: left; width: 150%;">
                                            <ul id="allowSpacesTags">
                                            </ul>
                                            <%--<span id="spLoading">Loading<img alt="Loading..." src="/Images/indicator.gif" /></span>--%>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-3 control-label">Active/Inactive<i>*</i></label>
                                    <div class="col-md-9">
                                        <asp:CheckBox ID="chkAlertActivate" runat="server" />
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-md-3 control-label">Frequency<i>*</i></label>
                                    <div class="col-md-9">
                                        <asp:RadioButtonList ID="rdoFrequency" runat="server" RepeatDirection="Vertical">
                                        </asp:RadioButtonList>
                                    </div>
                                </div>

                            </div>
                        </div>

                        <div class="parentclass" style="visibility: hidden">
                            <div class="ControlDiv">
                                <label class="formLevel">Country(*)</label>
                                <asp:DropDownList ID="ddlCountry" runat="server" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator15" runat="server" ControlToValidate="ddlCountry" ErrorMessage="Email address missing"
                                    Text="*" ValidationGroup="valJobAlert" Font-Bold="true" ForeColor="Red" Font-Size="Large"></asp:RequiredFieldValidator>
                            </div>
                        </div>

                        <div class="parentclass" style="visibility: hidden">
                            <div class="ControlDiv">
                                <label class="formLevel">City(*)</label>
                                <asp:DropDownList ID="ddlCity" runat="server">
                                </asp:DropDownList>
                            </div>
                        </div>

                        <div class="parentclass">
                            <div class="ControlDiv" style="visibility: hidden">
                                <label class="formLevel">Work Type</label>
                                <asp:DropDownList ID="ddlWorkType" CssClass="formddl" runat="server" AppendDataBoundItems="true"
                                    SelectMethod="Load_CareerLevel" DataTextField="Type" DataValueField="ID">
                                    <asp:ListItem Value="-1" Text="--Select a career level --"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                        </div>

                        <div class="parentclass" style="visibility: hidden">
                            <div class="ControlDiv">
                                <label class="formLevel">Salary Range</label>
                                <asp:DropDownList ID="ddlSalaryRange" CssClass="formddl" runat="server" AppendDataBoundItems="true"
                                    SelectMethod="Load_SalaryRange" DataTextField="Range" DataValueField="ID">
                                    <asp:ListItem Value="-1" Text="--Select a salary range --"></asp:ListItem>
                                </asp:DropDownList>
                            </div>
                        </div>


                    </div>
                </div>
            </div>
            <!--Form End Here-->

            <!--Upload Resume Information Start Here-->
            <div class="edit-profile-form">
                <div class="row form-row">
                    <!--Form Start Here-->
                    <div class="row form-body submit">
                        <div>
                            <asp:Label ID="lblSaveMsg1" runat="server" Font-Size="Medium" Font-Italic="true" Font-Bold="true" ForeColor="Green"></asp:Label>
                        </div>
                        <div class=" col-md-8 pull-right text-right">
                            <asp:Button ID="btnSave" runat="server" OnClientClick="" OnClick="btnSave_Click" ValidationGroup="Alert" class="btn btn-primary orange-gradiant float-shadow" Text="Save" />
                            <asp:Button ID="btnAddNew" Text="Add New" runat="server" OnClick="btnAddNew_Click" OnClientClick="return ClearAll();" class="btn btn-primary orange-gradiant float-shadow" />
                            <asp:Button ID="btnClear" Text="Clear" runat="server" Visible="false" OnClick="btnClear_Click" OnClientClick="return ClearTagsString();" class="btn btn-primary orange-gradiant float-shadow" />
                            <asp:HiddenField ID="hdJobalertID" runat="server" />
                        </div>
                    </div>
                    <!--Form End Here-->
                </div>
            </div>
            <!--Upload Resume Information End Here-->
            <div class="edit-profile-form">
                <div class="row form-row">
                    <div class="col-md-12">
                        <div class="form-horizontal manage-profile" role="form">
                            <asp:GridView ID="gvData" runat="server" BorderStyle="None" Width="40%" BorderWidth="0" GridLines="None" AutoGenerateColumns="false" DataKeyNames="JobAlertID" OnRowDataBound="gvData_RowDataBound">
                                <Columns>
                                    <asp:BoundField DataField="AlertName" HeaderText="List of alerts" ItemStyle-CssClass="hide" />
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="lnkAlert" ForeColor="Blue" Font-Underline="true" runat="server" CommandName="Details" OnCommand="lnkAlert_Command" CommandArgument='<%# Eval("JobAlertID") %>'><%# Eval("AlertName") %></asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkActive" Font-Underline="false" runat="server" Checked='<%# Eval("IsActive") %>' CssClass="visibleFalse"></asp:CheckBox>
                                            <asp:Label ID="lblStatus" runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgDelete" runat="server" CommandName="del" OnClick="imgDelete_Click" ImageUrl="~/Images/delete.png" Width="20" Height="20" CommandArgument='<%# Eval("JobAlertID") %>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </div>

                        <asp:Button ID="btnShowPopup" runat="server" Style="display: none" />
                        <ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlpopup"
                            CancelControlID="btnNo" BackgroundCssClass="modalBackground">
                        </ajax:ModalPopupExtender>

                        <asp:Panel ID="pnlpopup" runat="server" BackColor="White" Height="100px" Width="400px" Style="display: none">
                            <div id="confirmOverlay">
                                <div id="confirmBox">

                                    <h1>Delete saved job(s)</h1>
                                    <p id="lblText" runat="server"></p>

                                    <div id="confirmButtons">
                                        <asp:ImageButton ID="btnYes" OnClick="btnYes_Click" runat="server" ImageUrl="~/Images/btnyes.jpg" />
                                        <asp:ImageButton ID="btnNo" runat="server" ImageUrl="~/Images/btnNo.jpg" />
                                    </div>
                                </div>
                            </div>
                        </asp:Panel>
                    </div>
                </div>
            </div>

        </ContentTemplate>
    </asp:UpdatePanel>
    <script src="../Scripts/outside.js"></script>
</asp:Content>
